<?php

// +----------------------------------------------------------------------
// | MC PHP[基于ThinkPHP6.1开发]
// +----------------------------------------------------------------------
// | Copyright (c) 2020-2023 http://www.mingchangruanjian.com
// +----------------------------------------------------------------------
// | Author jokerfei [ jokerfei377@gmail.com ]
// +----------------------------------------------------------------------
// | 铭畅软件 技术部 出品
// +----------------------------------------------------------------------


namespace app\api\controller\v1;

use app\api\controller\Base;
use app\common\service\ApiReturn;
use think\facade\Db;
use app\common\model\Order;
use app\admin\model\user\User;
/**
 * 系统管理
 */
class System extends Base
{
    /** 
     * @Author: Bryant  
     * @Date: 2023-06-14 12:21:18 
     * @method post 
     * @title 获取系统单页 
     */
    public function articleList($data=[],$user=[])
    {
        $where[] = ['status','=',1];
        $where[] = ['id','=',$data['type']];
        $info = \app\admin\model\system\SystemArticle::where($where)->field('id,image,content')->find();
        if(!$info){
            return ApiReturn::r(0,[],'没有数据');
        }
        // $info['content'] = htmlspecialchars_decode($info['content']);
        return ApiReturn::r(1,$info,'请求成功');
    }
    /** 
     * @Author: Bryant  
     * @Date: 2023-06-14 19:02:11 
     * @method post 
     * @title APP更新 
     */
    public function versionLog($data=[],$user=[])
    {
        $where[] = ['status','=',1];
        $where[] = ['plat','=',$data['plat']];
        $where[] = ['port','=',$data['port']];
        $info = \app\admin\model\system\SystemVersionLog::where($where)->order('id desc')
        ->field('url,version_name,version,type,is_force,readme,size')
        ->find();
        if(!$info){
            return ApiReturn::r(0,[],'暂无更新');
        }
        if ($info['is_plan'] == 2 && time() < $info['plan_time']) {
            return ApiReturn::r(0,[],'计划更新,还未到更新时间');
        }
        return ApiReturn::r(1,$info,'请求成功');
    }
    /** 
     * @Author: Bryant  
     * @Date: 2024-12-16 11:54:59 
     * @method post 
     * @title 获取系统配置 
     */
    public function getSystemConfig($data,$user)
    {
        $info = sysconfig($data['module']);
        return ApiReturn::r(1,$info,'ok');
    }
}